package androidx.core.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.FocusFinder;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View.BaseSavedState;
import android.view.View.MeasureSpec;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AnimationUtils;
import android.widget.EdgeEffect;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.OverScroller;
import android.widget.ScrollView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.view.ViewCompat;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.util.List;
import o.hc;
import o.hn;
import o.hr;
import o.hu;
import o.hv;
import o.in;
import o.io;
import o.it;

public class NestedScrollView extends FrameLayout implements hv, hn {
    private static final d ʾ = new d();
    private static final int[] ʿ = new int[]{16843130};
    private boolean ʻ;
    private int ʻॱ;
    private int ʼ;
    private int ʼॱ;
    private View ʽ;
    private final hu ʽॱ;
    private SavedState ˈ;
    private final Rect ˊ;
    private final hr ˊˋ;
    private int ˊॱ;
    private c ˊᐝ;
    private OverScroller ˋ;
    private float ˋˊ;
    private boolean ˋॱ;
    private EdgeEffect ˎ;
    private EdgeEffect ˏ;
    private int ˏॱ;
    private boolean ͺ;
    private long ॱ;
    private VelocityTracker ॱˊ;
    private final int[] ॱˋ;
    private int ॱˎ;
    private boolean ॱॱ;
    private int ॱᐝ;
    private boolean ᐝ;
    private final int[] ᐝॱ;

    public interface c {
        void ˏ(NestedScrollView nestedScrollView, int i, int i2, int i3, int i4);
    }

    static class SavedState extends BaseSavedState {
        public static final Creator<SavedState> CREATOR = new Creator<SavedState>() {
            public /* synthetic */ Object createFromParcel(Parcel parcel) {
                return ˊ(parcel);
            }

            public /* synthetic */ Object[] newArray(int i) {
                return ˊ(i);
            }

            public SavedState ˊ(Parcel parcel) {
                return new SavedState(parcel);
            }

            public SavedState[] ˊ(int i) {
                return new SavedState[i];
            }
        };
        public int ˏ;

        SavedState(Parcelable parcelable) {
            super(parcelable);
        }

        SavedState(Parcel parcel) {
            super(parcel);
            this.ˏ = parcel.readInt();
        }

        public void writeToParcel(Parcel parcel, int i) {
            super.writeToParcel(parcel, i);
            parcel.writeInt(this.ˏ);
        }

        public String toString() {
            return "HorizontalScrollView.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " scrollPosition=" + this.ˏ + "}";
        }
    }

    static class d extends hc {
        d() {
        }

        public boolean ˊ(View view, int i, Bundle bundle) {
            if (super.ˊ(view, i, bundle)) {
                return true;
            }
            NestedScrollView nestedScrollView = (NestedScrollView) view;
            if (!nestedScrollView.isEnabled()) {
                return false;
            }
            int min;
            switch (i) {
                case 4096:
                    min = Math.min(((nestedScrollView.getHeight() - nestedScrollView.getPaddingBottom()) - nestedScrollView.getPaddingTop()) + nestedScrollView.getScrollY(), nestedScrollView.ˏ());
                    if (min == nestedScrollView.getScrollY()) {
                        return false;
                    }
                    nestedScrollView.ˋ(0, min);
                    return true;
                case 8192:
                    min = Math.max(nestedScrollView.getScrollY() - ((nestedScrollView.getHeight() - nestedScrollView.getPaddingBottom()) - nestedScrollView.getPaddingTop()), 0);
                    if (min == nestedScrollView.getScrollY()) {
                        return false;
                    }
                    nestedScrollView.ˋ(0, min);
                    return true;
                default:
                    return false;
            }
        }

        public void ˋ(View view, in inVar) {
            super.ˋ(view, inVar);
            NestedScrollView nestedScrollView = (NestedScrollView) view;
            inVar.ˏ(ScrollView.class.getName());
            if (nestedScrollView.isEnabled()) {
                int ˏ = nestedScrollView.ˏ();
                if (ˏ > 0) {
                    inVar.ˏॱ(true);
                    if (nestedScrollView.getScrollY() > 0) {
                        inVar.ˊ(8192);
                    }
                    if (nestedScrollView.getScrollY() < ˏ) {
                        inVar.ˊ(4096);
                    }
                }
            }
        }

        public void ˎ(View view, AccessibilityEvent accessibilityEvent) {
            super.ˎ(view, accessibilityEvent);
            NestedScrollView nestedScrollView = (NestedScrollView) view;
            accessibilityEvent.setClassName(ScrollView.class.getName());
            accessibilityEvent.setScrollable(nestedScrollView.ˏ() > 0);
            accessibilityEvent.setScrollX(nestedScrollView.getScrollX());
            accessibilityEvent.setScrollY(nestedScrollView.getScrollY());
            io.ˊ(accessibilityEvent, nestedScrollView.getScrollX());
            io.ˏ(accessibilityEvent, nestedScrollView.ˏ());
        }
    }

    public NestedScrollView(@NonNull Context context) {
        this(context, null);
    }

    public NestedScrollView(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public NestedScrollView(@NonNull Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ˊ = new Rect();
        this.ॱॱ = true;
        this.ᐝ = false;
        this.ʽ = null;
        this.ʻ = false;
        this.ͺ = true;
        this.ॱᐝ = -1;
        this.ᐝॱ = new int[2];
        this.ॱˋ = new int[2];
        ˎ();
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, ʿ, i, 0);
        setFillViewport(obtainStyledAttributes.getBoolean(0, false));
        obtainStyledAttributes.recycle();
        this.ʽॱ = new hu(this);
        this.ˊˋ = new hr(this);
        setNestedScrollingEnabled(true);
        ViewCompat.ˏ(this, ʾ);
    }

    public void ˎ(int i, int i2, int i3, int i4, @Nullable int[] iArr, int i5, @NonNull int[] iArr2) {
        this.ˊˋ.ˋ(i, i2, i3, i4, iArr, i5, iArr2);
    }

    public boolean ˊ(int i, int i2) {
        return this.ˊˋ.ˊ(i, i2);
    }

    public void ˊ(int i) {
        this.ˊˋ.ˎ(i);
    }

    public boolean ˏ(int i) {
        return this.ˊˋ.ॱ(i);
    }

    public boolean ˊ(int i, int i2, int[] iArr, int[] iArr2, int i3) {
        return this.ˊˋ.ॱ(i, i2, iArr, iArr2, i3);
    }

    public void setNestedScrollingEnabled(boolean z) {
        this.ˊˋ.ˊ(z);
    }

    public boolean isNestedScrollingEnabled() {
        return this.ˊˋ.ˏ();
    }

    public boolean startNestedScroll(int i) {
        return ˊ(i, 0);
    }

    public void stopNestedScroll() {
        ˊ(0);
    }

    public boolean hasNestedScrollingParent() {
        return ˏ(0);
    }

    public boolean dispatchNestedScroll(int i, int i2, int i3, int i4, int[] iArr) {
        return this.ˊˋ.ˊ(i, i2, i3, i4, iArr);
    }

    public boolean dispatchNestedPreScroll(int i, int i2, int[] iArr, int[] iArr2) {
        return ˊ(i, i2, iArr, iArr2, 0);
    }

    public boolean dispatchNestedFling(float f, float f2, boolean z) {
        return this.ˊˋ.ˊ(f, f2, z);
    }

    public boolean dispatchNestedPreFling(float f, float f2) {
        return this.ˊˋ.ˎ(f, f2);
    }

    public void ॱ(@NonNull View view, int i, int i2, int i3, int i4, int i5, @NonNull int[] iArr) {
        ˏ(i4, i5, iArr);
    }

    private void ˏ(int i, int i2, @Nullable int[] iArr) {
        int scrollY = getScrollY();
        scrollBy(0, i);
        int scrollY2 = getScrollY() - scrollY;
        if (iArr != null) {
            iArr[1] = iArr[1] + scrollY2;
        }
        this.ˊˋ.ˋ(0, scrollY2, 0, i - scrollY2, null, i2, iArr);
    }

    public boolean ˊ(@NonNull View view, @NonNull View view2, int i, int i2) {
        return (i & 2) != 0;
    }

    public void ˏ(@NonNull View view, @NonNull View view2, int i, int i2) {
        this.ʽॱ.ˎ(view, view2, i, i2);
        ˊ(2, i2);
    }

    public void ˏ(@NonNull View view, int i) {
        this.ʽॱ.ˋ(view, i);
        ˊ(i);
    }

    public void ˋ(@NonNull View view, int i, int i2, int i3, int i4, int i5) {
        ˏ(i4, i5, null);
    }

    public void ˊ(@NonNull View view, int i, int i2, @NonNull int[] iArr, int i3) {
        ˊ(i, i2, iArr, null, i3);
    }

    public boolean onStartNestedScroll(View view, View view2, int i) {
        return ˊ(view, view2, i, 0);
    }

    public void onNestedScrollAccepted(View view, View view2, int i) {
        ˏ(view, view2, i, 0);
    }

    public void onStopNestedScroll(View view) {
        ˏ(view, 0);
    }

    public void onNestedScroll(View view, int i, int i2, int i3, int i4) {
        ˏ(i4, 0, null);
    }

    public void onNestedPreScroll(View view, int i, int i2, int[] iArr) {
        ˊ(view, i, i2, iArr, 0);
    }

    public boolean onNestedFling(View view, float f, float f2, boolean z) {
        if (z) {
            return false;
        }
        dispatchNestedFling(0.0f, f2, true);
        ʻ((int) f2);
        return true;
    }

    public boolean onNestedPreFling(View view, float f, float f2) {
        return dispatchNestedPreFling(f, f2);
    }

    public int getNestedScrollAxes() {
        return this.ʽॱ.ॱ();
    }

    public boolean shouldDelayChildPressedState() {
        return true;
    }

    protected float getTopFadingEdgeStrength() {
        if (getChildCount() == 0) {
            return 0.0f;
        }
        int verticalFadingEdgeLength = getVerticalFadingEdgeLength();
        int scrollY = getScrollY();
        if (scrollY < verticalFadingEdgeLength) {
            return ((float) scrollY) / ((float) verticalFadingEdgeLength);
        }
        return 1.0f;
    }

    protected float getBottomFadingEdgeStrength() {
        if (getChildCount() == 0) {
            return 0.0f;
        }
        View childAt = getChildAt(0);
        LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
        int verticalFadingEdgeLength = getVerticalFadingEdgeLength();
        int bottom = ((layoutParams.bottomMargin + childAt.getBottom()) - getScrollY()) - (getHeight() - getPaddingBottom());
        if (bottom < verticalFadingEdgeLength) {
            return ((float) bottom) / ((float) verticalFadingEdgeLength);
        }
        return 1.0f;
    }

    public int ˋ() {
        return (int) (0.5f * ((float) getHeight()));
    }

    private void ˎ() {
        this.ˋ = new OverScroller(getContext());
        setFocusable(true);
        setDescendantFocusability(262144);
        setWillNotDraw(false);
        ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext());
        this.ˏॱ = viewConfiguration.getScaledTouchSlop();
        this.ˊॱ = viewConfiguration.getScaledMinimumFlingVelocity();
        this.ʻॱ = viewConfiguration.getScaledMaximumFlingVelocity();
    }

    public void addView(View view) {
        if (getChildCount() > 0) {
            throw new IllegalStateException("ScrollView can host only one direct child");
        }
        super.addView(view);
    }

    public void addView(View view, int i) {
        if (getChildCount() > 0) {
            throw new IllegalStateException("ScrollView can host only one direct child");
        }
        super.addView(view, i);
    }

    public void addView(View view, ViewGroup.LayoutParams layoutParams) {
        if (getChildCount() > 0) {
            throw new IllegalStateException("ScrollView can host only one direct child");
        }
        super.addView(view, layoutParams);
    }

    public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
        if (getChildCount() > 0) {
            throw new IllegalStateException("ScrollView can host only one direct child");
        }
        super.addView(view, i, layoutParams);
    }

    public void setOnScrollChangeListener(@Nullable c cVar) {
        this.ˊᐝ = cVar;
    }

    private boolean ˊ() {
        if (getChildCount() <= 0) {
            return false;
        }
        View childAt = getChildAt(0);
        LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
        if (layoutParams.bottomMargin + (childAt.getHeight() + layoutParams.topMargin) > (getHeight() - getPaddingTop()) - getPaddingBottom()) {
            return true;
        }
        return false;
    }

    public void setFillViewport(boolean z) {
        if (z != this.ˋॱ) {
            this.ˋॱ = z;
            requestLayout();
        }
    }

    public void setSmoothScrollingEnabled(boolean z) {
        this.ͺ = z;
    }

    protected void onScrollChanged(int i, int i2, int i3, int i4) {
        super.onScrollChanged(i, i2, i3, i4);
        if (this.ˊᐝ != null) {
            this.ˊᐝ.ˏ(this, i, i2, i3, i4);
        }
    }

    protected void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        if (this.ˋॱ && MeasureSpec.getMode(i2) != 0 && getChildCount() > 0) {
            View childAt = getChildAt(0);
            LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
            int measuredHeight = (((getMeasuredHeight() - getPaddingTop()) - getPaddingBottom()) - layoutParams.topMargin) - layoutParams.bottomMargin;
            if (childAt.getMeasuredHeight() < measuredHeight) {
                childAt.measure(getChildMeasureSpec(i, ((getPaddingLeft() + getPaddingRight()) + layoutParams.leftMargin) + layoutParams.rightMargin, layoutParams.width), MeasureSpec.makeMeasureSpec(measuredHeight, 1073741824));
            }
        }
    }

    public boolean dispatchKeyEvent(KeyEvent keyEvent) {
        return super.dispatchKeyEvent(keyEvent) || ˊ(keyEvent);
    }

    public boolean ˊ(@NonNull KeyEvent keyEvent) {
        int i = 33;
        this.ˊ.setEmpty();
        if (ˊ()) {
            if (keyEvent.getAction() != 0) {
                return false;
            }
            switch (keyEvent.getKeyCode()) {
                case 19:
                    if (keyEvent.isAltPressed()) {
                        return ॱ(33);
                    }
                    return ˎ(33);
                case 20:
                    if (keyEvent.isAltPressed()) {
                        return ॱ(130);
                    }
                    return ˎ(130);
                case o.fc.c.ⁱ /*62*/:
                    if (!keyEvent.isShiftPressed()) {
                        i = 130;
                    }
                    ˋ(i);
                    return false;
                default:
                    return false;
            }
        } else if (!isFocused() || keyEvent.getKeyCode() == 4) {
            return false;
        } else {
            boolean z;
            View findFocus = findFocus();
            if (findFocus == this) {
                findFocus = null;
            }
            findFocus = FocusFinder.getInstance().findNextFocus(this, findFocus, 130);
            if (findFocus == null || findFocus == this || !findFocus.requestFocus(130)) {
                z = false;
            } else {
                z = true;
            }
            return z;
        }
    }

    private boolean ˎ(int i, int i2) {
        if (getChildCount() <= 0) {
            return false;
        }
        int scrollY = getScrollY();
        View childAt = getChildAt(0);
        if (i2 < childAt.getTop() - scrollY || i2 >= childAt.getBottom() - scrollY || i < childAt.getLeft() || i >= childAt.getRight()) {
            return false;
        }
        return true;
    }

    private void ॱ() {
        if (this.ॱˊ == null) {
            this.ॱˊ = VelocityTracker.obtain();
        } else {
            this.ॱˊ.clear();
        }
    }

    private void ʼ() {
        if (this.ॱˊ == null) {
            this.ॱˊ = VelocityTracker.obtain();
        }
    }

    private void ॱॱ() {
        if (this.ॱˊ != null) {
            this.ॱˊ.recycle();
            this.ॱˊ = null;
        }
    }

    public void requestDisallowInterceptTouchEvent(boolean z) {
        if (z) {
            ॱॱ();
        }
        super.requestDisallowInterceptTouchEvent(z);
    }

    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        boolean z = true;
        int action = motionEvent.getAction();
        if (action == 2 && this.ʻ) {
            return true;
        }
        switch (action & 255) {
            case 0:
                action = (int) motionEvent.getY();
                if (!ˎ((int) motionEvent.getX(), action)) {
                    this.ʻ = false;
                    ॱॱ();
                    break;
                }
                this.ʼ = action;
                this.ॱᐝ = motionEvent.getPointerId(0);
                ॱ();
                this.ॱˊ.addMovement(motionEvent);
                this.ˋ.computeScrollOffset();
                if (this.ˋ.isFinished()) {
                    z = false;
                }
                this.ʻ = z;
                ˊ(2, 0);
                break;
            case 1:
            case 3:
                this.ʻ = false;
                this.ॱᐝ = -1;
                ॱॱ();
                if (this.ˋ.springBack(getScrollX(), getScrollY(), 0, 0, 0, ˏ())) {
                    ViewCompat.ˎ(this);
                }
                ˊ(0);
                break;
            case 2:
                action = this.ॱᐝ;
                if (action != -1) {
                    int findPointerIndex = motionEvent.findPointerIndex(action);
                    if (findPointerIndex != -1) {
                        action = (int) motionEvent.getY(findPointerIndex);
                        if (Math.abs(action - this.ʼ) > this.ˏॱ && (getNestedScrollAxes() & 2) == 0) {
                            this.ʻ = true;
                            this.ʼ = action;
                            ʼ();
                            this.ॱˊ.addMovement(motionEvent);
                            this.ॱˎ = 0;
                            ViewParent parent = getParent();
                            if (parent != null) {
                                parent.requestDisallowInterceptTouchEvent(true);
                                break;
                            }
                        }
                    }
                    Log.e("NestedScrollView", "Invalid pointerId=" + action + " in onInterceptTouchEvent");
                    break;
                }
                break;
            case 6:
                ˊ(motionEvent);
                break;
        }
        return this.ʻ;
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        ʼ();
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            this.ॱˎ = 0;
        }
        MotionEvent obtain = MotionEvent.obtain(motionEvent);
        obtain.offsetLocation(0.0f, (float) this.ॱˎ);
        ViewParent parent;
        switch (actionMasked) {
            case 0:
                if (getChildCount() != 0) {
                    boolean z = !this.ˋ.isFinished();
                    this.ʻ = z;
                    if (z) {
                        parent = getParent();
                        if (parent != null) {
                            parent.requestDisallowInterceptTouchEvent(true);
                        }
                    }
                    if (!this.ˋ.isFinished()) {
                        ʻ();
                    }
                    this.ʼ = (int) motionEvent.getY();
                    this.ॱᐝ = motionEvent.getPointerId(0);
                    ˊ(2, 0);
                    break;
                }
                return false;
            case 1:
                VelocityTracker velocityTracker = this.ॱˊ;
                velocityTracker.computeCurrentVelocity(1000, (float) this.ʻॱ);
                actionMasked = (int) velocityTracker.getYVelocity(this.ॱᐝ);
                if (Math.abs(actionMasked) > this.ˊॱ) {
                    if (!dispatchNestedPreFling(0.0f, (float) (-actionMasked))) {
                        dispatchNestedFling(0.0f, (float) (-actionMasked), true);
                        ʻ(-actionMasked);
                    }
                } else if (this.ˋ.springBack(getScrollX(), getScrollY(), 0, 0, 0, ˏ())) {
                    ViewCompat.ˎ(this);
                }
                this.ॱᐝ = -1;
                ᐝ();
                break;
            case 2:
                int findPointerIndex = motionEvent.findPointerIndex(this.ॱᐝ);
                if (findPointerIndex != -1) {
                    int y = (int) motionEvent.getY(findPointerIndex);
                    int i = this.ʼ - y;
                    if (ˊ(0, i, this.ॱˋ, this.ᐝॱ, 0)) {
                        i -= this.ॱˋ[1];
                        this.ॱˎ += this.ᐝॱ[1];
                    }
                    if (!this.ʻ && Math.abs(i) > this.ˏॱ) {
                        parent = getParent();
                        if (parent != null) {
                            parent.requestDisallowInterceptTouchEvent(true);
                        }
                        this.ʻ = true;
                        if (i > 0) {
                            i -= this.ˏॱ;
                        } else {
                            i += this.ˏॱ;
                        }
                    }
                    if (this.ʻ) {
                        Object obj;
                        this.ʼ = y - this.ᐝॱ[1];
                        int scrollY = getScrollY();
                        y = ˏ();
                        actionMasked = getOverScrollMode();
                        if (actionMasked == 0 || (actionMasked == 1 && y > 0)) {
                            obj = 1;
                        } else {
                            obj = null;
                        }
                        if (ˏ(0, i, 0, getScrollY(), 0, y, 0, 0, true) && !ˏ(0)) {
                            this.ॱˊ.clear();
                        }
                        int scrollY2 = getScrollY() - scrollY;
                        int i2 = i - scrollY2;
                        this.ॱˋ[1] = 0;
                        ˎ(0, scrollY2, 0, i2, this.ᐝॱ, 0, this.ॱˋ);
                        this.ʼ -= this.ᐝॱ[1];
                        this.ॱˎ += this.ᐝॱ[1];
                        if (obj != null) {
                            actionMasked = i - this.ॱˋ[1];
                            ˊॱ();
                            int i3 = scrollY + actionMasked;
                            if (i3 < 0) {
                                it.ॱ(this.ˏ, ((float) actionMasked) / ((float) getHeight()), motionEvent.getX(findPointerIndex) / ((float) getWidth()));
                                if (!this.ˎ.isFinished()) {
                                    this.ˎ.onRelease();
                                }
                            } else if (i3 > y) {
                                it.ॱ(this.ˎ, ((float) actionMasked) / ((float) getHeight()), 1.0f - (motionEvent.getX(findPointerIndex) / ((float) getWidth())));
                                if (!this.ˏ.isFinished()) {
                                    this.ˏ.onRelease();
                                }
                            }
                            if (!(this.ˏ == null || (this.ˏ.isFinished() && this.ˎ.isFinished()))) {
                                ViewCompat.ˎ(this);
                                break;
                            }
                        }
                    }
                }
                Log.e("NestedScrollView", "Invalid pointerId=" + this.ॱᐝ + " in onTouchEvent");
                break;
                break;
            case 3:
                if (this.ʻ && getChildCount() > 0 && this.ˋ.springBack(getScrollX(), getScrollY(), 0, 0, 0, ˏ())) {
                    ViewCompat.ˎ(this);
                }
                this.ॱᐝ = -1;
                ᐝ();
                break;
            case 5:
                actionMasked = motionEvent.getActionIndex();
                this.ʼ = (int) motionEvent.getY(actionMasked);
                this.ॱᐝ = motionEvent.getPointerId(actionMasked);
                break;
            case 6:
                ˊ(motionEvent);
                this.ʼ = (int) motionEvent.getY(motionEvent.findPointerIndex(this.ॱᐝ));
                break;
        }
        if (this.ॱˊ != null) {
            this.ॱˊ.addMovement(obtain);
        }
        obtain.recycle();
        return true;
    }

    private void ˊ(MotionEvent motionEvent) {
        int actionIndex = motionEvent.getActionIndex();
        if (motionEvent.getPointerId(actionIndex) == this.ॱᐝ) {
            actionIndex = actionIndex == 0 ? 1 : 0;
            this.ʼ = (int) motionEvent.getY(actionIndex);
            this.ॱᐝ = motionEvent.getPointerId(actionIndex);
            if (this.ॱˊ != null) {
                this.ॱˊ.clear();
            }
        }
    }

    public boolean onGenericMotionEvent(MotionEvent motionEvent) {
        if ((motionEvent.getSource() & 2) == 0) {
            return false;
        }
        switch (motionEvent.getAction()) {
            case 8:
                if (this.ʻ) {
                    return false;
                }
                float axisValue = motionEvent.getAxisValue(9);
                if (axisValue == 0.0f) {
                    return false;
                }
                int ʽ = (int) (axisValue * ʽ());
                int ˏ = ˏ();
                int scrollY = getScrollY();
                ʽ = scrollY - ʽ;
                if (ʽ < 0) {
                    ˏ = 0;
                } else if (ʽ <= ˏ) {
                    ˏ = ʽ;
                }
                if (ˏ == scrollY) {
                    return false;
                }
                super.scrollTo(getScrollX(), ˏ);
                return true;
            default:
                return false;
        }
    }

    private float ʽ() {
        if (this.ˋˊ == 0.0f) {
            TypedValue typedValue = new TypedValue();
            Context context = getContext();
            if (context.getTheme().resolveAttribute(16842829, typedValue, true)) {
                this.ˋˊ = typedValue.getDimension(context.getResources().getDisplayMetrics());
            } else {
                throw new IllegalStateException("Expected theme to define listPreferredItemHeight.");
            }
        }
        return this.ˋˊ;
    }

    protected void onOverScrolled(int i, int i2, boolean z, boolean z2) {
        super.scrollTo(i, i2);
    }

    boolean ˏ(int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, boolean z) {
        boolean z2;
        boolean z3;
        int overScrollMode = getOverScrollMode();
        Object obj = computeHorizontalScrollRange() > computeHorizontalScrollExtent() ? 1 : null;
        Object obj2 = computeVerticalScrollRange() > computeVerticalScrollExtent() ? 1 : null;
        Object obj3 = (overScrollMode == 0 || (overScrollMode == 1 && obj != null)) ? 1 : null;
        obj = (overScrollMode == 0 || (overScrollMode == 1 && obj2 != null)) ? 1 : null;
        int i9 = i3 + i;
        if (obj3 == null) {
            i7 = 0;
        }
        int i10 = i4 + i2;
        if (obj == null) {
            i8 = 0;
        }
        int i11 = -i7;
        int i12 = i7 + i5;
        overScrollMode = -i8;
        int i13 = i8 + i6;
        if (i9 > i12) {
            z2 = true;
        } else if (i9 < i11) {
            z2 = true;
            i12 = i11;
        } else {
            z2 = false;
            i12 = i9;
        }
        if (i10 > i13) {
            z3 = true;
        } else if (i10 < overScrollMode) {
            z3 = true;
            i13 = overScrollMode;
        } else {
            z3 = false;
            i13 = i10;
        }
        if (z3 && !ˏ(1)) {
            this.ˋ.springBack(i12, i13, 0, 0, 0, ˏ());
        }
        onOverScrolled(i12, i13, z2, z3);
        if (z2 || z3) {
            return true;
        }
        return false;
    }

    int ˏ() {
        if (getChildCount() <= 0) {
            return 0;
        }
        View childAt = getChildAt(0);
        LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
        return Math.max(0, (layoutParams.bottomMargin + (childAt.getHeight() + layoutParams.topMargin)) - ((getHeight() - getPaddingTop()) - getPaddingBottom()));
    }

    private View ˏ(boolean z, int i, int i2) {
        List focusables = getFocusables(2);
        View view = null;
        Object obj = null;
        int size = focusables.size();
        int i3 = 0;
        while (i3 < size) {
            View view2;
            Object obj2;
            View view3 = (View) focusables.get(i3);
            int top = view3.getTop();
            int bottom = view3.getBottom();
            if (i < bottom && top < i2) {
                Object obj3 = (i >= top || bottom >= i2) ? null : 1;
                if (view == null) {
                    Object obj4 = obj3;
                    view2 = view3;
                    obj2 = obj4;
                } else {
                    Object obj5 = ((!z || top >= view.getTop()) && (z || bottom <= view.getBottom())) ? null : 1;
                    if (obj != null) {
                        if (!(obj3 == null || obj5 == null)) {
                            view2 = view3;
                            obj2 = obj;
                        }
                    } else if (obj3 != null) {
                        view2 = view3;
                        int i4 = 1;
                    } else if (obj5 != null) {
                        view2 = view3;
                        obj2 = obj;
                    }
                }
                i3++;
                view = view2;
                obj = obj2;
            }
            obj2 = obj;
            view2 = view;
            i3++;
            view = view2;
            obj = obj2;
        }
        return view;
    }

    public boolean ˋ(int i) {
        int i2 = i == 130 ? 1 : 0;
        int height = getHeight();
        if (i2 != 0) {
            this.ˊ.top = getScrollY() + height;
            i2 = getChildCount();
            if (i2 > 0) {
                View childAt = getChildAt(i2 - 1);
                i2 = (((LayoutParams) childAt.getLayoutParams()).bottomMargin + childAt.getBottom()) + getPaddingBottom();
                if (this.ˊ.top + height > i2) {
                    this.ˊ.top = i2 - height;
                }
            }
        } else {
            this.ˊ.top = getScrollY() - height;
            if (this.ˊ.top < 0) {
                this.ˊ.top = 0;
            }
        }
        this.ˊ.bottom = this.ˊ.top + height;
        return ˋ(i, this.ˊ.top, this.ˊ.bottom);
    }

    public boolean ॱ(int i) {
        int i2 = i == 130 ? 1 : 0;
        int height = getHeight();
        this.ˊ.top = 0;
        this.ˊ.bottom = height;
        if (i2 != 0) {
            i2 = getChildCount();
            if (i2 > 0) {
                View childAt = getChildAt(i2 - 1);
                this.ˊ.bottom = (((LayoutParams) childAt.getLayoutParams()).bottomMargin + childAt.getBottom()) + getPaddingBottom();
                this.ˊ.top = this.ˊ.bottom - height;
            }
        }
        return ˋ(i, this.ˊ.top, this.ˊ.bottom);
    }

    private boolean ˋ(int i, int i2, int i3) {
        boolean z = false;
        int height = getHeight();
        int scrollY = getScrollY();
        int i4 = scrollY + height;
        boolean z2 = i == 33;
        View ˏ = ˏ(z2, i2, i3);
        if (ˏ == null) {
            ˏ = this;
        }
        if (i2 < scrollY || i3 > i4) {
            ॱॱ(z2 ? i2 - scrollY : i3 - i4);
            z = true;
        }
        if (ˏ != findFocus()) {
            ˏ.requestFocus(i);
        }
        return z;
    }

    public boolean ˎ(int i) {
        View view;
        int scrollY;
        View findFocus = findFocus();
        if (findFocus == this) {
            view = null;
        } else {
            view = findFocus;
        }
        findFocus = FocusFinder.getInstance().findNextFocus(this, view, i);
        int ˋ = ˋ();
        if (findFocus == null || !ॱ(findFocus, ˋ, getHeight())) {
            if (i == 33 && getScrollY() < ˋ) {
                scrollY = getScrollY();
            } else if (i != 130 || getChildCount() <= 0) {
                scrollY = ˋ;
            } else {
                View childAt = getChildAt(0);
                LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
                scrollY = Math.min((layoutParams.bottomMargin + childAt.getBottom()) - ((getScrollY() + getHeight()) - getPaddingBottom()), ˋ);
            }
            if (scrollY == 0) {
                return false;
            }
            if (i != 130) {
                scrollY = -scrollY;
            }
            ॱॱ(scrollY);
        } else {
            findFocus.getDrawingRect(this.ˊ);
            offsetDescendantRectToMyCoords(findFocus, this.ˊ);
            ॱॱ(ॱ(this.ˊ));
            findFocus.requestFocus(i);
        }
        if (view != null && view.isFocused() && ˏ(view)) {
            scrollY = getDescendantFocusability();
            setDescendantFocusability(WXMediaMessage.MINI_PROGRAM__THUMB_LENGHT);
            requestFocus();
            setDescendantFocusability(scrollY);
        }
        return true;
    }

    private boolean ˏ(View view) {
        return !ॱ(view, 0, getHeight());
    }

    private boolean ॱ(View view, int i, int i2) {
        view.getDrawingRect(this.ˊ);
        offsetDescendantRectToMyCoords(view, this.ˊ);
        return this.ˊ.bottom + i >= getScrollY() && this.ˊ.top - i <= getScrollY() + i2;
    }

    private void ॱॱ(int i) {
        if (i == 0) {
            return;
        }
        if (this.ͺ) {
            ॱ(0, i);
        } else {
            scrollBy(0, i);
        }
    }

    public final void ॱ(int i, int i2) {
        if (getChildCount() != 0) {
            if (AnimationUtils.currentAnimationTimeMillis() - this.ॱ > 250) {
                View childAt = getChildAt(0);
                LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
                int height = layoutParams.bottomMargin + (childAt.getHeight() + layoutParams.topMargin);
                int height2 = (getHeight() - getPaddingTop()) - getPaddingBottom();
                int scrollY = getScrollY();
                this.ˋ.startScroll(getScrollX(), scrollY, 0, Math.max(0, Math.min(scrollY + i2, Math.max(0, height - height2))) - scrollY);
                ˊ(false);
            } else {
                if (!this.ˋ.isFinished()) {
                    ʻ();
                }
                scrollBy(i, i2);
            }
            this.ॱ = AnimationUtils.currentAnimationTimeMillis();
        }
    }

    public final void ˋ(int i, int i2) {
        ॱ(i - getScrollX(), i2 - getScrollY());
    }

    @RestrictTo({androidx.annotation.RestrictTo.d.LIBRARY_GROUP_PREFIX})
    public int computeVerticalScrollRange() {
        int height = (getHeight() - getPaddingBottom()) - getPaddingTop();
        if (getChildCount() == 0) {
            return height;
        }
        View childAt = getChildAt(0);
        LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
        int bottom = layoutParams.bottomMargin + childAt.getBottom();
        int scrollY = getScrollY();
        height = Math.max(0, bottom - height);
        if (scrollY < 0) {
            return bottom - scrollY;
        }
        if (scrollY > height) {
            return bottom + (scrollY - height);
        }
        return bottom;
    }

    @RestrictTo({androidx.annotation.RestrictTo.d.LIBRARY_GROUP_PREFIX})
    public int computeVerticalScrollOffset() {
        return Math.max(0, super.computeVerticalScrollOffset());
    }

    @RestrictTo({androidx.annotation.RestrictTo.d.LIBRARY_GROUP_PREFIX})
    public int computeVerticalScrollExtent() {
        return super.computeVerticalScrollExtent();
    }

    @RestrictTo({androidx.annotation.RestrictTo.d.LIBRARY_GROUP_PREFIX})
    public int computeHorizontalScrollRange() {
        return super.computeHorizontalScrollRange();
    }

    @RestrictTo({androidx.annotation.RestrictTo.d.LIBRARY_GROUP_PREFIX})
    public int computeHorizontalScrollOffset() {
        return super.computeHorizontalScrollOffset();
    }

    @RestrictTo({androidx.annotation.RestrictTo.d.LIBRARY_GROUP_PREFIX})
    public int computeHorizontalScrollExtent() {
        return super.computeHorizontalScrollExtent();
    }

    protected void measureChild(View view, int i, int i2) {
        view.measure(getChildMeasureSpec(i, getPaddingLeft() + getPaddingRight(), view.getLayoutParams().width), MeasureSpec.makeMeasureSpec(0, 0));
    }

    protected void measureChildWithMargins(View view, int i, int i2, int i3, int i4) {
        MarginLayoutParams marginLayoutParams = (MarginLayoutParams) view.getLayoutParams();
        view.measure(getChildMeasureSpec(i, (((getPaddingLeft() + getPaddingRight()) + marginLayoutParams.leftMargin) + marginLayoutParams.rightMargin) + i2, marginLayoutParams.width), MeasureSpec.makeMeasureSpec(marginLayoutParams.bottomMargin + marginLayoutParams.topMargin, 0));
    }

    public void computeScroll() {
        if (!this.ˋ.isFinished()) {
            this.ˋ.computeScrollOffset();
            int currY = this.ˋ.getCurrY();
            int i = currY - this.ʼॱ;
            this.ʼॱ = currY;
            this.ॱˋ[1] = 0;
            ˊ(0, i, this.ॱˋ, null, 1);
            i -= this.ॱˋ[1];
            int ˏ = ˏ();
            if (i != 0) {
                int scrollY = getScrollY();
                ˏ(0, i, getScrollX(), scrollY, 0, ˏ, 0, 0, false);
                int scrollY2 = getScrollY() - scrollY;
                int i2 = i - scrollY2;
                this.ॱˋ[1] = 0;
                ˎ(0, scrollY2, 0, i2, this.ᐝॱ, 1, this.ॱˋ);
                i = i2 - this.ॱˋ[1];
            }
            if (i != 0) {
                currY = getOverScrollMode();
                Object obj = (currY == 0 || (currY == 1 && ˏ > 0)) ? 1 : null;
                if (obj != null) {
                    ˊॱ();
                    if (i < 0) {
                        if (this.ˏ.isFinished()) {
                            this.ˏ.onAbsorb((int) this.ˋ.getCurrVelocity());
                        }
                    } else if (this.ˎ.isFinished()) {
                        this.ˎ.onAbsorb((int) this.ˋ.getCurrVelocity());
                    }
                }
                ʻ();
            }
            if (!this.ˋ.isFinished()) {
                ViewCompat.ˎ(this);
            }
        }
    }

    private void ˊ(boolean z) {
        if (z) {
            ˊ(2, 1);
        } else {
            ˊ(1);
        }
        this.ʼॱ = getScrollY();
        ViewCompat.ˎ(this);
    }

    private void ʻ() {
        this.ˋ.abortAnimation();
        ˊ(1);
    }

    private void ˋ(View view) {
        view.getDrawingRect(this.ˊ);
        offsetDescendantRectToMyCoords(view, this.ˊ);
        int ॱ = ॱ(this.ˊ);
        if (ॱ != 0) {
            scrollBy(0, ॱ);
        }
    }

    private boolean ˋ(Rect rect, boolean z) {
        int ॱ = ॱ(rect);
        boolean z2 = ॱ != 0;
        if (z2) {
            if (z) {
                scrollBy(0, ॱ);
            } else {
                ॱ(0, ॱ);
            }
        }
        return z2;
    }

    protected int ॱ(Rect rect) {
        if (getChildCount() == 0) {
            return 0;
        }
        int i;
        int height = getHeight();
        int scrollY = getScrollY();
        int i2 = scrollY + height;
        int verticalFadingEdgeLength = getVerticalFadingEdgeLength();
        if (rect.top > 0) {
            i = scrollY + verticalFadingEdgeLength;
        } else {
            i = scrollY;
        }
        View childAt = getChildAt(0);
        LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
        if (rect.bottom < (childAt.getHeight() + layoutParams.topMargin) + layoutParams.bottomMargin) {
            verticalFadingEdgeLength = i2 - verticalFadingEdgeLength;
        } else {
            verticalFadingEdgeLength = i2;
        }
        if (rect.bottom > verticalFadingEdgeLength && rect.top > i) {
            if (rect.height() > height) {
                i = (rect.top - i) + 0;
            } else {
                i = (rect.bottom - verticalFadingEdgeLength) + 0;
            }
            scrollY = Math.min(i, (layoutParams.bottomMargin + childAt.getBottom()) - i2);
        } else if (rect.top >= i || rect.bottom >= verticalFadingEdgeLength) {
            scrollY = 0;
        } else {
            if (rect.height() > height) {
                scrollY = 0 - (verticalFadingEdgeLength - rect.bottom);
            } else {
                scrollY = 0 - (i - rect.top);
            }
            scrollY = Math.max(scrollY, -getScrollY());
        }
        return scrollY;
    }

    public void requestChildFocus(View view, View view2) {
        if (this.ॱॱ) {
            this.ʽ = view2;
        } else {
            ˋ(view2);
        }
        super.requestChildFocus(view, view2);
    }

    protected boolean onRequestFocusInDescendants(int i, Rect rect) {
        View findNextFocus;
        if (i == 2) {
            i = 130;
        } else if (i == 1) {
            i = 33;
        }
        if (rect == null) {
            findNextFocus = FocusFinder.getInstance().findNextFocus(this, null, i);
        } else {
            findNextFocus = FocusFinder.getInstance().findNextFocusFromRect(this, rect, i);
        }
        if (findNextFocus == null || ˏ(findNextFocus)) {
            return false;
        }
        return findNextFocus.requestFocus(i, rect);
    }

    public boolean requestChildRectangleOnScreen(View view, Rect rect, boolean z) {
        rect.offset(view.getLeft() - view.getScrollX(), view.getTop() - view.getScrollY());
        return ˋ(rect, z);
    }

    public void requestLayout() {
        this.ॱॱ = true;
        super.requestLayout();
    }

    protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
        int i5 = 0;
        super.onLayout(z, i, i2, i3, i4);
        this.ॱॱ = false;
        if (this.ʽ != null && ˊ(this.ʽ, (View) this)) {
            ˋ(this.ʽ);
        }
        this.ʽ = null;
        if (!this.ᐝ) {
            if (this.ˈ != null) {
                scrollTo(getScrollX(), this.ˈ.ˏ);
                this.ˈ = null;
            }
            if (getChildCount() > 0) {
                View childAt = getChildAt(0);
                LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
                i5 = layoutParams.bottomMargin + (childAt.getMeasuredHeight() + layoutParams.topMargin);
            }
            int paddingTop = ((i4 - i2) - getPaddingTop()) - getPaddingBottom();
            int scrollY = getScrollY();
            i5 = ॱ(scrollY, paddingTop, i5);
            if (i5 != scrollY) {
                scrollTo(getScrollX(), i5);
            }
        }
        scrollTo(getScrollX(), getScrollY());
        this.ᐝ = true;
    }

    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        this.ᐝ = false;
    }

    protected void onSizeChanged(int i, int i2, int i3, int i4) {
        super.onSizeChanged(i, i2, i3, i4);
        View findFocus = findFocus();
        if (findFocus != null && this != findFocus && ॱ(findFocus, 0, i4)) {
            findFocus.getDrawingRect(this.ˊ);
            offsetDescendantRectToMyCoords(findFocus, this.ˊ);
            ॱॱ(ॱ(this.ˊ));
        }
    }

    private static boolean ˊ(View view, View view2) {
        if (view == view2) {
            return true;
        }
        ViewParent parent = view.getParent();
        boolean z = (parent instanceof ViewGroup) && ˊ((View) parent, view2);
        return z;
    }

    public void ʻ(int i) {
        if (getChildCount() > 0) {
            this.ˋ.fling(getScrollX(), getScrollY(), 0, i, 0, 0, Integer.MIN_VALUE, ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED, 0, 0);
            ˊ(true);
        }
    }

    private void ᐝ() {
        this.ʻ = false;
        ॱॱ();
        ˊ(0);
        if (this.ˏ != null) {
            this.ˏ.onRelease();
            this.ˎ.onRelease();
        }
    }

    public void scrollTo(int i, int i2) {
        if (getChildCount() > 0) {
            View childAt = getChildAt(0);
            LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
            int width = (childAt.getWidth() + layoutParams.leftMargin) + layoutParams.rightMargin;
            int height = (getHeight() - getPaddingTop()) - getPaddingBottom();
            int height2 = layoutParams.bottomMargin + (childAt.getHeight() + layoutParams.topMargin);
            int ॱ = ॱ(i, (getWidth() - getPaddingLeft()) - getPaddingRight(), width);
            height2 = ॱ(i2, height, height2);
            if (ॱ != getScrollX() || height2 != getScrollY()) {
                super.scrollTo(ॱ, height2);
            }
        }
    }

    private void ˊॱ() {
        if (getOverScrollMode() == 2) {
            this.ˏ = null;
            this.ˎ = null;
        } else if (this.ˏ == null) {
            Context context = getContext();
            this.ˏ = new EdgeEffect(context);
            this.ˎ = new EdgeEffect(context);
        }
    }

    public void draw(Canvas canvas) {
        int i = 0;
        super.draw(canvas);
        if (this.ˏ != null) {
            int width;
            int height;
            int min;
            int paddingLeft;
            int scrollY = getScrollY();
            if (!this.ˏ.isFinished()) {
                int save = canvas.save();
                width = getWidth();
                height = getHeight();
                min = Math.min(0, scrollY);
                if (VERSION.SDK_INT < 21 || getClipToPadding()) {
                    paddingLeft = width - (getPaddingLeft() + getPaddingRight());
                    width = getPaddingLeft() + 0;
                } else {
                    paddingLeft = width;
                    width = 0;
                }
                if (VERSION.SDK_INT >= 21 && getClipToPadding()) {
                    height -= getPaddingTop() + getPaddingBottom();
                    min += getPaddingTop();
                }
                canvas.translate((float) width, (float) min);
                this.ˏ.setSize(paddingLeft, height);
                if (this.ˏ.draw(canvas)) {
                    ViewCompat.ˎ(this);
                }
                canvas.restoreToCount(save);
            }
            if (!this.ˎ.isFinished()) {
                height = canvas.save();
                width = getWidth();
                min = getHeight();
                paddingLeft = Math.max(ˏ(), scrollY) + min;
                if (VERSION.SDK_INT < 21 || getClipToPadding()) {
                    width -= getPaddingLeft() + getPaddingRight();
                    i = 0 + getPaddingLeft();
                }
                if (VERSION.SDK_INT >= 21 && getClipToPadding()) {
                    min -= getPaddingTop() + getPaddingBottom();
                    paddingLeft -= getPaddingBottom();
                }
                canvas.translate((float) (i - width), (float) paddingLeft);
                canvas.rotate(180.0f, (float) width, 0.0f);
                this.ˎ.setSize(width, min);
                if (this.ˎ.draw(canvas)) {
                    ViewCompat.ˎ(this);
                }
                canvas.restoreToCount(height);
            }
        }
    }

    private static int ॱ(int i, int i2, int i3) {
        if (i2 >= i3 || i < 0) {
            return 0;
        }
        if (i2 + i > i3) {
            return i3 - i2;
        }
        return i;
    }

    protected void onRestoreInstanceState(Parcelable parcelable) {
        if (parcelable instanceof SavedState) {
            SavedState savedState = (SavedState) parcelable;
            super.onRestoreInstanceState(savedState.getSuperState());
            this.ˈ = savedState;
            requestLayout();
            return;
        }
        super.onRestoreInstanceState(parcelable);
    }

    protected Parcelable onSaveInstanceState() {
        Parcelable savedState = new SavedState(super.onSaveInstanceState());
        savedState.ˏ = getScrollY();
        return savedState;
    }
}
